#ifndef __OP_LIST_H__
#define __OP_LIST_H__
#include "common.h"

typedef struct Operand_* Operand;
typedef struct InterCodes InterCodes;
typedef struct CodesList_ * CodesList; 
typedef unsigned long long uLL;
typedef uLL * active_status;

struct Operand_{
    enum{VARIABLE,CONSTANT,CONST_F,LABEL,NAME} kind;
    int offset,pos;
    InterCodes * entry;
    union{
        int var_no;
        int value;
        float f;
        int label;
        char * name;
    }u;
};

typedef struct InterCode{
    enum {LABL,FUNC,ASSIGN,ADD,SUB,MUL,OP_DIV,GTADDR,TOADDR,ASSADDR,GOTO,OP_IF,RET,DEC,ARG,CALL,PARAM,READ,WRITE,EXTRA_INST} kind;
    Operand x,y,z;
    int info;
    int nx,ny,nz;
}InterCode;

typedef struct basic_block * BB;
struct InterCodes {
    InterCode code;
    BB block;
    int run,nr_num;
    active_status in,out;
    struct InterCodes *prev, *next;
};

extern InterCodes * first_op, * end_op;
void op_pb(int kind,Operand x,Operand y,Operand z,int info);
void output_op(FILE *);
Operand wrap_op1(unsigned x,int kind);
Operand wrap_op2(char * info,int kind);
Operand wrap_op3(float f,int kind);
void active_var_analyse(InterCodes * first);
void read_ir(FILE * f);
#endif
